// --------------------------------------------------------------------------------------------------------------------
// <copyright file="BaseTypeRequiredAttribute.cs" company="CSLib.Net Team">
//   Copyright (c) Roman "4ux-nbIx" Novitsky 2010
// </copyright>
// <summary>
//   When applied to target attribute, specifies a requirement for any type which is marked with
//   target attribute to implement or inherit specific type or types.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace CSLib.Net.Annotations
{
  #region Namespace Imports

  using System;
  using System.Collections.Generic;

  #endregion


  /// <summary>
  /// When applied to target attribute, specifies a requirement for any type which is marked with 
  /// target attribute to implement or inherit specific type or types.
  /// </summary>
  /// <example>
  /// <code>
  /// [BaseTypeRequired(typeof(IComponent)] // Specify requirement
  /// public class ComponentAttribute : Attribute 
  /// {}
  /// [Component] // ComponentAttribute requires implementing IComponent interface
  /// public class MyComponent : IComponent
  /// {}
  /// </code>
  /// </example>
  [AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)]
  [BaseTypeRequired(typeof(Attribute))]
  public sealed class BaseTypeRequiredAttribute : Attribute
  {
    #region Constants and Fields

    private readonly Type[] _baseTypes;

    #endregion


    #region Constructors and Destructors

    /// <summary>
    /// Initializes a new instance of the <see cref="BaseTypeRequiredAttribute"/> class. 
    /// Initializes new instance of BaseTypeRequiredAttribute.
    /// </summary>
    /// <param name="baseTypes">
    /// Specifies which types are required.
    /// </param>
    public BaseTypeRequiredAttribute(params Type[] baseTypes)
    {
      _baseTypes = baseTypes;
    }

    #endregion


    #region Properties

    /// <summary>
    /// Gets enumerations of specified base types.
    /// </summary>
    /// <value>
    /// The base types.
    /// </value>
    public IEnumerable<Type> BaseTypes
    {
      get
      {
        return _baseTypes;
      }
    }

    #endregion
  }
}